{template 'common/header'}
{template 'navs'}
<div class="panel panel-default">
    <div class="panel-heading">
        添加快捷菜单
    </div>
    <div class="panel-body">
        <form action="" method="post"  class="form-horizontal" enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">排序</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" name="displayorder" placeholder="" value="{$item['displayorder']}" class="form-control"/>
                    <span class="help-block">越大越靠前</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">标题</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" name="title" placeholder="" value="{$item['title']}" class="form-control"/>
                    <span class="help-block">
                        两个字以内
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">图标</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    {php echo tpl_form_field_icon('icon',$item['icon'])}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">链接</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <div class="input-group">
                        <input type="text" value="{php echo $item['link']}" name="link" class="form-control" autocomplete="off">
		                <span class="input-group-btn">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">选择链接 <span class="caret"></span></button>
                            <ul class="dropdown-menu">
                                <li><a href="javascript:" data-type="system" onclick="showRunnerDialog(this);">模块菜单</a></li>
                            </ul>
                        </span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">激活do</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" name="ido" placeholder="" value="{$item['ido']}" class="form-control"/>
                    <span class="help-block"></span>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11">
                    <input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    require(['util'],function(util){
        util.runnerBrowser = function(callback){
            var footer = '<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>';
            var modalobj = util.dialog('请选择链接',['{php echo $this->createWebUrl('link')}&callback=selectLinkComplete'],footer,{containerName:'link-container'});
            modalobj.modal({'keyboard': false});
            modalobj.find('.modal-body').css({'height':'300px','overflow-y':'auto' });
            modalobj.modal('show');

            window.selectLinkComplete = function(link){
                if($.isFunction(callback)){
                    callback(link);
                    modalobj.modal('hide');
                }
            };
        };
    });
    function showRunnerDialog(elm){
        require(["util","jquery"], function(u, $){
            var ipt = $(elm).parent().parent().parent().prev();
            u.runnerBrowser(function(href){
                var multiid = "{$_GPC['multiid']}";
                if (multiid) {
                    href = /(&)?t=/.test(href) ? href : href + "&t=" + multiid;
                }
                ipt.val(href);
            });
        });
    }
</script>
{template 'common/footer'}